//首页焦点广告图切换
(function($) {
	$.fn.jfocus = function(settings) {
		var defaults = {
			time: 5000
		};
		var settings = $.extend(defaults, settings);
		return this.each(function(){
			var $this = $(this);
			var sWidth = $this.width();
			var len = $this.find("ul li").length;
			var index = 0;
			var picTimer;
			var btn = "<div class='pagination'>";
			for (var i = 0; i < len; i++) {
				btn += "<span></span>";
			}
			btn += "</div><div class='arrow pre'></div><div class='arrow next'></div>";
			$this.append(btn);
			$this.find(".pagination span").css("opacity", 0.4).mouseenter(function() {
				index = $this.find(".pagination span").index(this);
				showPics(index);
			}).eq(0).trigger("mouseenter");
			$this.find(".arrow").css("opacity", 0.0).hover(function() {
				$(this).stop(true, false).animate({
					"opacity": "0.5"
				},
				300);
			},
			function() {
				$(this).stop(true, false).animate({
					"opacity": "0"
				},
				300);
			});
			$this.find(".pre").click(function() {
				index -= 1;
				if (index == -1) {
					index = len - 1;
				}
				showPics(index);
			});
			$this.find(".next").click(function() {
				index += 1;
				if (index == len) {
					index = 0;
				}
				showPics(index);
			});
			$this.find("ul").css("width", sWidth * (len));
			$this.hover(function() {
				clearInterval(picTimer);
			},
			function() {
				picTimer = setInterval(function() {
					showPics(index);
					index++;
					if (index == len) {
						index = 0;
					}
				},
				settings.time);
			}).trigger("mouseleave");
			function showPics(index) {
				var nowLeft = -index * sWidth;
				$this.find("ul").stop(true, false).animate({
					"left": nowLeft
				},
				300);
				$this.find(".pagination span").stop(true, false).animate({
					"opacity": "0.4"
				},
				300).eq(index).stop(true, false).animate({
					"opacity": "1"
				},
				300);
			}
		});
	}
//首页标准模块中间多图广告鼠标触及凸显
	$.fn.jfade = function(settings) {
		var defaults = {
			start_opacity: "1",
			high_opacity: "1",
			low_opacity: ".1",
			timing: "500"
		};
		var settings = $.extend(defaults, settings);
		settings.element = $(this);
		//set opacity to start
		$(settings.element).css("opacity", settings.start_opacity);
		//mouse over
		$(settings.element).hover(
		//mouse in
		function() {
			$(this).stop().animate({
				opacity: settings.high_opacity
			},
			settings.timing); //100% opacity for hovered object
			$(this).siblings().stop().animate({
				opacity: settings.low_opacity
			},
			settings.timing); //dimmed opacity for other objects
		},
		//mouse out
		function() {
			$(this).stop().animate({
				opacity: settings.start_opacity
			},
			settings.timing); //return hovered object to start opacity
			$(this).siblings().stop().animate({
				opacity: settings.start_opacity
			},
			settings.timing); // return other objects to start opacity
		});
		return this;
	}
})(jQuery);

function DOTCHANGE() {
	var changenow = $(this).index();
	$('#fullScreenSlides li').eq(nownow).css('z-index', '900');
	$('#fullScreenSlides li').eq(changenow).css({
		'z-index': '800'
	}).show();
	pagination.eq(changenow).addClass('current').siblings('li').removeClass('current');
	$('#fullScreenSlides li').eq(nownow).fadeOut(400,
	function() {
		$('#fullScreenSlides li').eq(changenow).fadeIn(500);
	});
	nownow = changenow;
}
function ADDLI() {
	for (var i = 0; i <= numpic; i++) {
		ulcontent += '<li>' + '<a href="#">' + (i + 1) + '</a>' + '</li>';
	}
	$('#fullScreenSlides').after(ulstart + ulcontent + ulend);
}
function GOGO() {
	var NN = nownow + 1;
	if (inout == 1) {} else {
		if (nownow < numpic) {
			$('#fullScreenSlides li').eq(nownow).css('z-index', '900');
			$('#fullScreenSlides li').eq(NN).css({
				'z-index': '800'
			}).show();
			pagination.eq(NN).addClass('current').siblings('li').removeClass('current');
			$('#fullScreenSlides li').eq(nownow).fadeOut(400,
			function() {
				$('#fullScreenSlides li').eq(NN).fadeIn(500);
			});
			nownow += 1;
		} else {
			NN = 0;
			$('#fullScreenSlides li').eq(nownow).css('z-index', '900');
			$('#fullScreenSlides li').eq(NN).stop(true, true).css({
				'z-index': '800'
			}).show();
			$('#fullScreenSlides li').eq(nownow).fadeOut(400,
			function() {
				$('#fullScreenSlides li').eq(0).fadeIn(500);
			});
			pagination.eq(NN).addClass('current').siblings('li').removeClass('current');
			nownow = 0;
		}
	}
	TT = setTimeout(GOGO, SPEED);
}
//首页焦点区满屏背景广告切换
var numpic = $('#fullScreenSlides li').size() - 1;
var nownow = 0;
var inout = 0;
var TT = 0;
var SPEED = 5000;
$('#fullScreenSlides li').eq(0).siblings('li').css({
	'display': 'none'
});
var ulstart = '<ul id="SlidesPagination" class="full-screen-slides-pagination">',
ulcontent = '',
ulend = '</ul>';
ADDLI();
var pagination = $('#SlidesPagination li');
var paginationwidth = $('#SlidesPagination').width();
//$('#SlidesPagination').css('margin-left', (600 - paginationwidth))
//alert(paginationwidth);
pagination.eq(0).addClass('current');
pagination.on('click', DOTCHANGE);
pagination.mouseenter(function() {
	inout = 1;
})
pagination.mouseleave(function() {
	inout = 0;
})
TT = setTimeout(GOGO, SPEED);


$(function () {
    $('#tab-list-li li').click(function () {
		var liindex = $('#tab-list-li li').index(this);
		$(this).addClass('ph').siblings().removeClass('ph');
		$('.linksQWap div.tab-con').eq(liindex).fadeIn(150).siblings('div.tab-con').hide();
	});
});